<?php
/**
 * 项目动作模型
 * @author qianxun
 *
 */
class proActModel extends MY_Model{
    function proActModel(){
        parent::MY_Model();
        $this->table = 'ProAct';
    }
    /**
     * 获取制定项目下的标准动作列表
     * @param number $projectId
     */
    function getActListByProId($projectId){
        //所有动作列表
        $actList = $this->getList(array('proId'=>$projectId,'isDel'=>0),'','','actId,actTitle,actDesc','orderNum ASC,actId ASC');
        $newActList = array();
        foreach($actList as $v){
            $v['itemList'] = array();
            $newActList[(int)$v['actId']] = $v;
        }
        //所有项目内的题目列表
        $this->load->model('proActItemModel');
        $actItemList = $this->proActItemModel->getNewList(array('proId'=>$projectId,'isDel'=>0),'','','itemId,proId,actId,type,itemTitle,itemDesc,isRequired,otherData','orderNum ASC,itemId ASC');
        foreach ($actItemList as $v){
            if(isset($newActList[(int)$v['actId']])){
                $newActList[(int)$v['actId']]['itemList'][(int)$v['itemId']] = $v;
            }
        }
        //加入动作题目序号名称
        $actSortCon = array(
            1 => '动作一',2 => '动作二',3 => '动作三',4 => '动作四',5 => '动作五',6 => '动作六',7 => '动作七',8 => '动作八',9 => '动作九',10 => '动作十',
            11 => '动作十一',12 => '动作十二',13 => '动作十三',14 => '动作十四',15 => '动作十五',16 => '动作十六',17 => '动作十七',18 => '动作十八',19 => '动作十九',20 => '动作二十',
        );
        $i = 1;
        foreach ($newActList as $actK => $actV){
            $actV['actTitle'] = isset($actSortCon[$i]) ? $actSortCon[$i].'、'.$actV['actTitle'] : $actV['actTitle'];
            $j = 1;
            foreach ($actV['itemList'] as $itemK => $itemV){
                $itemV['itemTitle'] = $j.'、'.$itemV['itemTitle'];
                $actV['itemList'][$itemK] = $itemV;
                $j ++;
            }
            $newActList[$actK] = $actV;
            $i ++;
        }
        return $newActList;
    }
}